<?php
ob_start();


    $email=urlencode($_POST['email']);
    $password=urlencode($_POST['password']);
    $password1=urlencode($_POST['password1']);
    $name= urlencode($_POST['companyname']);
    $logo= urlencode("esa/img/unknowicon.jpg");
    $description=urlencode($_POST['description']);

    
   // print_r($name); break;
     if($description=="") $description=NULL;

try{
               
       include_once('restconnection.php');
         
         if(isset($client)){
            
            //retrive base url 
            $url = $_SESSION['basic_url'];
            //add service url
            $service_url="/RegisterCompany?";
            //params url
            $params = array('email'=>$email,'password'=>$password,'logo'=>$logo,'name'=>$name,'description'=>$description);
            //params connection
            $ctx = stream_context_create(array('http' => array('timeout' => 30))); 
            //send GET request
            $final_url=$url.$service_url."email=".$params['email']."&"."password=".$params['password']."&"."logo=".$logo."&"."name=".$params['name']."&"."description=".$params['description'];
            //print_r($url.$service_url."email=".$params['email']."&"."password=".$params['password']."&"."logo=".$logo."&"."name=".$params['name']."&"."description=".$params['description']);
            //break;
            $output = @file_get_contents($final_url,0,$ctx);
            //parse JSON output
            // echo$url.$service_url."email=".$params['email']."&"."password=".$params['password']."&"."logo=".$params['logo']."&"."name=".$params['name']."&"."description=".$params['description']; break;
            $data = json_decode($output);
            $webResult = $data->RegisterCompanyResult;
      
          //  print_r($webResult); break;

        if(($webResult==true)||($webResult==1)){ ?>
           <script>$myjquery('#loading').addClass('hidden');</script> 
           <label style="color:#3EC03A;font-size:15px;">Registration Successful!</label><br/>
           <label><a><element onclick=" var link='esa/login_page.php'; ovv_mainother(link);" > Click to continue </a></label>

        <?php
        }else{

        ?>
          <script>$myjquery('#loading').addClass('hidden');</script> 
          <label style="color:red;font-size:15px;">Registration Error!<br/>Email already exists</label><br/>
          <label><a><element onclick=" var link='esa/registration.php'; ovv_mainother(link);" > Click to continue </a></label>
          
        <?php
        }

    }else{
       
          header("Location: login_page.php");  
    }

}catch(Exception $e) {
    ?>
          <label style="color:red;font-size:15px;">Sorry Connection Error!</label><br/>
          <label><a><element onclick=" var link='esa/login_page.php'; ovv_mainother(link);" > Click to continue </a></label>
          
    <?php      
    
}
?>


